﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
//using LTP.Accounts.Bus;
namespace xxxy.Web.workInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int wid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(wid);
				}
			}
		}
			
	private void ShowInfo(int wid)
	{
		xxxy.BLL.workInfo bll=new xxxy.BLL.workInfo();
		xxxy.Model.workInfo model=bll.GetModel(wid);
		this.lblwid.Text=model.wid.ToString();
		this.txtwname.Text=model.wname.ToString();
		this.txtwcontent.Text=model.wcontent;
		this.txtwtime.Text=model.wtime.ToString();
		this.txtwstate.Text=model.wstate.ToString();
		this.txtwtype.Text=model.wtype.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtwname.Text))
			{
				strErr+="姓名格式错误！\\n";	
			}
			if(this.txtwcontent.Text.Trim().Length==0)
			{
				strErr+="工作内容不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtwtime.Text))
			{
				strErr+="提交时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtwstate.Text))
			{
				strErr+="审核状态格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtwtype.Text))
			{
				strErr+="工作类型格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int wid=int.Parse(this.lblwid.Text);
			int wname=int.Parse(this.txtwname.Text);
			string wcontent=this.txtwcontent.Text;
			DateTime wtime=DateTime.Parse(this.txtwtime.Text);
			int wstate=int.Parse(this.txtwstate.Text);
			int wtype=int.Parse(this.txtwtype.Text);


			xxxy.Model.workInfo model=new xxxy.Model.workInfo();
			model.wid=wid;
			model.wname=wname;
			model.wcontent=wcontent;
			model.wtime=wtime;
			model.wstate=wstate;
			model.wtype=wtype;

			xxxy.BLL.workInfo bll=new xxxy.BLL.workInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
